#
# Makefile, Makefile.in
# Makefiles for the System Administrator Interface (SAI) of the Protea Project
# Copyright (C) 2008 Bruce A. James
#
# This file is part of the Protea Project.
#
# The Protea Project is free software; you can redistribute it and/or modify it 
# under the terms of the GNU General Public License as published by the 
# Free Software Foundation, either version 3 of the License, or (at your 
# option) any later version.
#
# The Protea Project is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
# for more details.
# 
# You should have received a copy of the GNU General Public License along 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Please send correspondence to:
#
# theproteaproject@gmail.com
#

PROGRAMS = sai.trans
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ @INTERNAL_FLAG@ @PICFLAG@ -D__REENTRANT
COMPILE = $(CXX) $(CXXFLAGS)
LIBS = @LIBS@ -L../.. -lprotea$(TOOLSBASE)

LDFLAGS=@LDFLAGS@ @PICFLAG@
LINK=$(CXX) $(LDFLAGS)

SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,%.o,$(SRCS))
DEPS := $(patsubst %.cpp,%.d,$(SRCS))

INSTALL = /@INSTALL@

all : $(PROGRAMS)

install:
	@echo "Installing System Admin components"
	@$(INSTALL) -d $(XSIROOT)/Tools/SAI
	@$(INSTALL) $(PROGRAMS) $(XSIROOT)/Tools/SAI

clean :
	-rm $(PROGRAMS) $(OBJS) $(DEPS)

%.d: %.cpp
	@echo "Creating dependency file: $*.d"
	@set -e; g++ -MM -I$(XERCESCROOT)/include $< \
	| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	[ -s $@ ] || rm -f $@

%.cpp: %.txn xcmacro
	xcmacro xcmacro.h $< $@

%.o: %.cpp
	@echo "Compiling source file: $*.cpp"
	@set -e; $(COMPILE) -o $@ -c $<

sai.trans : $(OBJS)
	@echo "Link sai"
	@$(LINK) @LDSHFLAGS@ -o $@ $(LIBS) $(OBJS)

depend: $(DEPS)

-include $(DEPS)
